/*
 * @Author: your name
 * @Date: 2021-03-12 14:54:21
 * @LastEditTime: 2021-04-10 14:29:22
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \test\src\router\index.js
 */
import Vue from 'vue'
import VueRouter from 'vue-router'

const LOGIN_ROUTE = () => import('@/components/login/login.vue')
const Register = () => import('@/components/login/register.vue')
const HomeIndex = () => import('../views/home/home.vue')

// 功能页面路由
const Temperature = () => import('../views/function/temperature.vue')
const Out = () => import('../views/function/out.vue')
const Trip = () => import('../views/function/trip.vue')
const BasicInfo = () => import('../views/function/basicInfo.vue')
const Update = () => import('../views/function/update.vue')
const Address = () => import('../views/function/address.vue')
const User = () => import('../views/function/user.vue')
const UserAbnormal = () => import('../views/function/userAbnormal.vue')

// 解决路由重复报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'Login',
    component: LOGIN_ROUTE
  },
  {
    path: '/register',
    name: 'Register',
    component: Register
  },
  {
    path: '/home',
    name: 'HomeIndex',
    component: HomeIndex
  },
  {
    path: '/temperature',
    name: 'Temperature',
    component: Temperature
  },
  {
    path: '/out',
    name: 'Out',
    component: Out
  },
  {
    path: '/trip',
    name: 'Trip',
    component: Trip
  },
  {
    path: '/basicInfo',
    name: 'BasicInfo',
    component: BasicInfo
  },
  {
    path: '/update',
    name: 'Update',
    component: Update
  },
  {
    path: '/address',
    name: 'Address',
    component: Address
  },
  {
    path: '/user',
    name: 'User',
    component: User
  },
  {
    path: '/userAbnormal',
    name: 'UserAbnormal',
    component: UserAbnormal
  }
]

const router = new VueRouter({
  routes
})

export default router
